#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<long long> a(n, 0);
    for (int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    vector<long long> dp(n, 0);
    for (int i = 1;i < n - 1;i++)
    {
        //cerr<<i<<": ";
        long long x = a[i];
        if (i - 3 >= 0) x += dp[i - 3];
        dp[i] = max(dp[i - 1], x);
        //cerr<<dp[i]<<endl;
    }
    cout << dp[n - 2] << endl;
    return 0;
}
